#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/11/19 15:02|15:02
# @Author  : yangdingyi
# @File    : 最长公共前缀
# @Software: PyCharm
from typing import List


class Solution:
    def longestCommonPrefix(self, strs: List[str]) -> str:
        n = len(strs)
        if n <= 0:
            return ''
        i = 0
        s0 = strs[0]
        m = len(s0)
        ll = [m]
        for j in range(n):
            ll.append(len(strs[j]))
        while i < m:
            for j in range(1, n):
                # if i == 0:
                #     ll.append(len(strs[j]))
                if i >= ll[j] or strs[j][i] != s0[i]:
                    return s0[:i]
            i += 1
        return s0
